package com.curluin.controll;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class MenuScreen extends Activity implements OnClickListener {
	private Button exitButton,startButton,nextButton,prevButton;
	private int levelNumber;
	private final static int[] levelPreviews = {R.drawable.level1, R.drawable.level2};
	private static final String LOG_TAG = "MenuScreen";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/DESTROY.ttf");
		
		setContentView(R.layout.menulayout);
		exitButton = (Button) this.findViewById(R.id.bExit);
		exitButton.setTypeface(tf);
		startButton = (Button) this.findViewById(R.id.bStart);
		startButton.setTypeface(tf);
		nextButton = (Button) this.findViewById(R.id.bNext);
		prevButton = (Button) this.findViewById(R.id.bPrevious);
		exitButton.setOnClickListener(this);
		startButton.setOnClickListener(this);
		nextButton.setOnClickListener(this);
		prevButton.setOnClickListener(this);
		TextView tview= (TextView) this.findViewById(R.id.textViewAppName);
		tview.setTypeface(tf);
		
	}



	@Override
	public void onClick(View v) {
		if(v.getId()==R.id.bStart) {
			Intent newGameScreen= new Intent(this, Controller.class);
			newGameScreen.putExtra("levelNumber", levelNumber);
			startActivity(newGameScreen);
			this.finish();
		}
		if(v.getId()==R.id.bExit){
			this.finish();
		}
		if(v.getId()==R.id.bNext){
			levelNumber = Math.min(levelPreviews.length-1, (levelNumber+1));
			ImageView img = (ImageView) findViewById(R.id.levelPreview);
			Log.w(LOG_TAG, "levelnumber "+levelNumber);
			img.setImageResource(levelPreviews[levelNumber]);
		}
		if(v.getId()==R.id.bPrevious){
			levelNumber = Math.max(0, (levelNumber-1));
			ImageView img = (ImageView) findViewById(R.id.levelPreview);
			Log.w(LOG_TAG, "levelnumber "+levelNumber);
			img.setImageResource(levelPreviews[levelNumber]);
		}
		
	}
}
